﻿Module modPestManagementService

    Function PestManagementService_EnableControl(ByRef oForm As SAPbouiCOM.Form, ByRef sErrDesc As String) As Long

        Try
            sFuncName = "PestManagementService_EnableControl()"
            If p_iDebugMode = DEBUG_ON Then Call WriteToLogFile_Debug("Starting Function", sFuncName)

            oForm.Items.Item("txtDocNum").Enabled = True
            oForm.Items.Item("txtDocDate").Enabled = True
            oForm.Items.Item("txtTimeIn").Enabled = True
            oForm.Items.Item("txtTimeOut").Enabled = True
            oForm.Items.Item("txtProject").Enabled = True
            oForm.Items.Item("txtAddress").Enabled = True
            oForm.Items.Item("txtReport").Enabled = True
            oForm.Items.Item("txtEmpty").Enabled = True
            oForm.Items.Item("txtBlkNo").Enabled = True

            oForm.Items.Item("txtUnitNo").Enabled = True
            oForm.Items.Item("txtPstCode").Enabled = True
            oForm.Items.Item("matPestmgt").Enabled = True
            oForm.Items.Item("txtSprName").Enabled = True
            oForm.Items.Item("txtEsign").Enabled = True

            oForm.Items.Item("txtCntName").Enabled = True
            oForm.Items.Item("txtESignt").Enabled = True
            oForm.Items.Item("37").Enabled = True
            oForm.Items.Item("38").Enabled = True
            oForm.Items.Item("39").Enabled = True

            oForm.Items.Item("41").Enabled = True
            oForm.Items.Item("43").Enabled = True
            oForm.Items.Item("45").Enabled = True
            oForm.Items.Item("46").Enabled = True
            oForm.Items.Item("48").Enabled = True

            oForm.ActiveItem = "txtDocNum"

            If p_iDebugMode = DEBUG_ON Then Call WriteToLogFile_Debug("Completed with SUCCESS", sFuncName)
            PestManagementService_EnableControl = RTN_SUCCESS

        Catch ex As Exception
            sErrDesc = ex.Message().ToString()
            Call WriteToLogFile(sErrDesc, sFuncName)
            If p_iDebugMode = DEBUG_ON Then Call WriteToLogFile_Debug("Completed with ERROR", sFuncName)
            PestManagementService_EnableControl = RTN_ERROR
        End Try
    End Function

    Function PestManagementService_DisableControl(ByRef oForm As SAPbouiCOM.Form, ByRef sErrDesc As String) As Long

        Try
            sFuncName = "PestManagementService_DisableControl()"
            If p_iDebugMode = DEBUG_ON Then Call WriteToLogFile_Debug("Starting Function", sFuncName)



            oForm.Items.Item("txtDocNum").Enabled = False
            oForm.Items.Item("txtDocDate").Enabled = False
            oForm.Items.Item("txtTimeIn").Enabled = False
            oForm.Items.Item("txtTimeOut").Enabled = False
            oForm.Items.Item("txtProject").Enabled = False
            oForm.Items.Item("txtAddress").Enabled = False
            oForm.Items.Item("txtReport").Enabled = False
            oForm.Items.Item("txtEmpty").Enabled = False
            oForm.Items.Item("txtBlkNo").Enabled = False

            oForm.Items.Item("txtUnitNo").Enabled = False
            oForm.Items.Item("txtPstCode").Enabled = False
            oForm.Items.Item("matPestmgt").Enabled = False
            oForm.Items.Item("54").Enabled = False
            oForm.Items.Item("txtSprName").Enabled = False
            oForm.Items.Item("txtEsign").Enabled = False

            oForm.Items.Item("txtCntName").Enabled = False
            oForm.Items.Item("txtESignt").Enabled = False
            oForm.Items.Item("37").Enabled = False
            oForm.Items.Item("38").Enabled = False
            oForm.Items.Item("39").Enabled = False

            oForm.Items.Item("41").Enabled = False
            oForm.Items.Item("43").Enabled = False
            oForm.Items.Item("45").Enabled = False
            oForm.Items.Item("46").Enabled = False
            oForm.Items.Item("48").Enabled = False

            If oForm.Mode <> SAPbouiCOM.BoFormMode.fm_OK_MODE Then
                oForm.ActiveItem = "txtDocEntr"
            End If

            If p_iDebugMode = DEBUG_ON Then Call WriteToLogFile_Debug("Completed with SUCCESS", sFuncName)
            PestManagementService_DisableControl = RTN_SUCCESS

        Catch ex As Exception
            sErrDesc = ex.Message().ToString()
            Call WriteToLogFile(sErrDesc, sFuncName)
            If p_iDebugMode = DEBUG_ON Then Call WriteToLogFile_Debug("Completed with ERROR", sFuncName)
            PestManagementService_DisableControl = RTN_ERROR
        End Try
    End Function

End Module
